package com.ny.demo5171;

import com.ny.demo5171.Emp;

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class TestSet {
    public static void main(String[] args) {
//        添加元素
        Emp emp1 = new Emp("1001","小乔",18);
        Emp emp2 = new Emp("1002","大乔",18);
        Set<Emp> set = new HashSet<>();
        set.add(emp1);
        set.add(emp2);
//        System.out.println(set);
//        查询所有员工信息
//        加强for循环，List集合也可以使用增强for
       for (Emp  emp: set){
           System.out.println(emp);
       }
        Scanner scanner = new Scanner(System.in);
       String ename = scanner.next();
//  根据姓名进行查询
        for (Emp  emp: set){
            if(ename.equals(emp.getName())){
            System.out.println(emp);
            }
        }
    }
}
